/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FramePrincipal.java
 *
 * Created on 27/12/2012, 01:23:11
 */
package inovacao.views;

import inovacao.gui.PanelBairro;
import inovacao.gui.PanelCidade;
import inovacao.gui.PanelCliente;
import inovacao.gui.PanelPesquisa;
import inovacao.gui.TESTEINTERNAL;
import inovacao.modelos.DesktopPane;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JToolBar;
import javax.swing.plaf.DimensionUIResource;

/**
 *
 * @author Giovani
 */
public class FramePrincipal extends javax.swing.JFrame {

    /** Creates new form FramePrincipal */
    public FramePrincipal() {
        super();
        this.setLayout(new BorderLayout());
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        initComponents();
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        this.setSize(screenSize.width, screenSize.height);
        this.setExtendedState(MAXIMIZED_BOTH);
        
        
        JPanel panelPrincipal = new JPanel(new BorderLayout());
        
        jDesktopPane1 = new DesktopPane();
        jDesktopPane1.setBackground(new java.awt.Color(204, 204, 204));
        
        
        javax.swing.GroupLayout layout1 = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout1);
        layout1.setHorizontalGroup(
                layout1.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout1.createSequentialGroup().addGap(25, 25, 25).addComponent(panelPrincipal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addContainerGap(710, Short.MAX_VALUE)));
        layout1.setVerticalGroup(
                layout1.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout1.createSequentialGroup().addContainerGap(95, Short.MAX_VALUE).addComponent(panelPrincipal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addGap(92, 92, 92)));
        
        
        panelPrincipal.add(jDesktopPane1);
        
        
        JToolBar jToolBar = new JToolBar();
        JButton jButtonCidade = new JButton();
        jButtonCidade.setIcon(new ImageIcon(getClass().getResource("/META-INF/imagens/city.png")));
        jButtonCidade.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                jMenuItemCidadesActionPerformed(e);
            }
        });
        
        JButton jButtonBairro = new JButton();
        jButtonBairro.setIcon(new ImageIcon(getClass().getResource("/META-INF/imagens/map.png")));
        jButtonBairro.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                jMenuItemBairrosActionPerformed(e);
            }
        });
        
        JButton jButtonCliente = new JButton();
        jButtonCliente.setIcon(new ImageIcon(getClass().getResource("/META-INF/imagens/cliente_1.png")));
        jButtonCliente.addActionListener(new ActionListener() {            
            @Override
            public void actionPerformed(ActionEvent e) {
                jMenuItemClientesActionPerformed(e);
            }
        });        
        
        jToolBar.add(jButtonCidade);
        jToolBar.add(jButtonBairro);
        jToolBar.add(jButtonCliente);
        
        
        jToolBar.setFloatable(false);
        
        
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(panelPrincipal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE));
        layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(panelPrincipal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE));
        
        panelPrincipal.add(jToolBar, BorderLayout.NORTH);
        panelPrincipal.add(jDesktopPane1, BorderLayout.CENTER);
        
        StatusBar statusBar = new StatusBar();
        panelPrincipal.add(statusBar, BorderLayout.SOUTH);
        
        
        this.add(panelPrincipal, BorderLayout.CENTER);
        
        
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItemCidades = new javax.swing.JMenuItem();
        jSeparator1 = new javax.swing.JPopupMenu.Separator();
        jMenuItemBairros = new javax.swing.JMenuItem();
        jSeparator2 = new javax.swing.JPopupMenu.Separator();
        jMenuItemClientes = new javax.swing.JMenuItem();
        jSeparator4 = new javax.swing.JPopupMenu.Separator();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItemConsultas = new javax.swing.JMenuItem();
        jSeparator3 = new javax.swing.JPopupMenu.Separator();
        jMenu2 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setName("Inovação"); // NOI18N

        jMenu1.setText("Cadastros");

        jMenuItemCidades.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItemCidades.setText("Manutenção de Cidades");
        jMenuItemCidades.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemCidadesActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItemCidades);
        jMenu1.add(jSeparator1);

        jMenuItemBairros.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_B, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItemBairros.setText("Manutenção de Bairros");
        jMenuItemBairros.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemBairrosActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItemBairros);
        jMenu1.add(jSeparator2);

        jMenuItemClientes.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItemClientes.setText("Manutenção de Clientes");
        jMenuItemClientes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemClientesActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItemClientes);
        jMenu1.add(jSeparator4);

        jMenuItem1.setText("jMenuItem1");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                testeInternal(evt);
            }
        });
        jMenu1.add(jMenuItem1);

        jMenuItemConsultas.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItemConsultas.setText("Consultas");
        jMenuItemConsultas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemConsultasActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItemConsultas);
        jMenu1.add(jSeparator3);

        jMenuBar1.add(jMenu1);
        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 855, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 298, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void jMenuItemCidadesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCidadesActionPerformed
// TODO add your handling code here: 

    if (!PanelCidade.getInstance().isVisible()) {
        jDesktopPane1.add(PanelCidade.getInstance());
        PanelCidade.getInstance().setClosable(true);
        PanelCidade.getInstance().setResizable(true);
        PanelCidade.getInstance().setRequestFocusEnabled(true);
        PanelCidade.getInstance().setMaximizable(true);
        PanelCidade.getInstance().setIconifiable(true);
        
        PanelCidade.getInstance().setClosable(true);
        PanelCidade.getInstance().setSize(jDesktopPane1.getWidth(), jDesktopPane1.getHeight());
        
        PanelCidade.getInstance().setMinimumSize(new DimensionUIResource(725, 600));
        PanelCidade.getInstance().setVisible(true);
    }
    
}//GEN-LAST:event_jMenuItemCidadesActionPerformed
    
private void jMenuItemBairrosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemBairrosActionPerformed
// TODO add your handling code here:
    if (!PanelBairro.getInstance().isVisible()) {
        jDesktopPane1.add(PanelBairro.getInstance());
        PanelBairro.getInstance().setClosable(true);
        PanelBairro.getInstance().setResizable(true);
        PanelBairro.getInstance().setRequestFocusEnabled(true);
        PanelBairro.getInstance().setMaximizable(true);
        PanelBairro.getInstance().setIconifiable(true);
        
        PanelBairro.getInstance().setClosable(true);
        PanelBairro.getInstance().setSize(jDesktopPane1.getWidth(), jDesktopPane1.getHeight());
        
        PanelBairro.getInstance().setMinimumSize(new DimensionUIResource(725, 600));
        PanelBairro.getInstance().setVisible(true);
    } else {
        jDesktopPane1.repaint();
    }
}//GEN-LAST:event_jMenuItemBairrosActionPerformed
    
private void jMenuItemClientesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemClientesActionPerformed
// TODO add your handling code here:
    if (!PanelCliente.getInstance().isVisible()) {
        jDesktopPane1.add(PanelCliente.getInstance());
        PanelCliente.getInstance().setClosable(true);
        PanelCliente.getInstance().setResizable(true);
        PanelCliente.getInstance().setRequestFocusEnabled(true);
        PanelCliente.getInstance().setMaximizable(true);
        PanelCliente.getInstance().setIconifiable(true);
        
        PanelCliente.getInstance().setClosable(true);
        PanelCliente.getInstance().setSize(jDesktopPane1.getWidth(), jDesktopPane1.getHeight());
        
        PanelCliente.getInstance().setMinimumSize(new DimensionUIResource(725, 600));
        PanelCliente.getInstance().setVisible(true);
    } else {
        jDesktopPane1.repaint();
    }
}//GEN-LAST:event_jMenuItemClientesActionPerformed

private void jMenuItemConsultasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemConsultasActionPerformed
// TODO add your handling code here:
     if (!PanelPesquisa.getInstance().isVisible()) {
        jDesktopPane1.add(PanelPesquisa.getInstance());
        PanelPesquisa.getInstance().setClosable(true);
        PanelPesquisa.getInstance().setResizable(true);
        PanelPesquisa.getInstance().setRequestFocusEnabled(true);
        PanelPesquisa.getInstance().setMaximizable(true);
        PanelPesquisa.getInstance().setIconifiable(true);
        
        PanelPesquisa.getInstance().setClosable(true);
        PanelPesquisa.getInstance().setSize(jDesktopPane1.getWidth(), jDesktopPane1.getHeight());
        
        PanelPesquisa.getInstance().setMinimumSize(new DimensionUIResource(725, 600));        
        PanelPesquisa.getInstance().setVisible(true);
    }
}//GEN-LAST:event_jMenuItemConsultasActionPerformed

private void testeInternal(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_testeInternal
// TODO add your handling code here:
    TESTEINTERNAL teste = new TESTEINTERNAL();
    jDesktopPane1.add(teste);
    teste.setVisible(true);
}//GEN-LAST:event_testeInternal

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(FramePrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(FramePrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(FramePrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(FramePrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            
            public void run() {
                new FramePrincipal().setVisible(true);
            }
        });
    }
    private javax.swing.JDesktopPane jDesktopPane1;
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItemBairros;
    private javax.swing.JMenuItem jMenuItemCidades;
    private javax.swing.JMenuItem jMenuItemClientes;
    private javax.swing.JMenuItem jMenuItemConsultas;
    private javax.swing.JPopupMenu.Separator jSeparator1;
    private javax.swing.JPopupMenu.Separator jSeparator2;
    private javax.swing.JPopupMenu.Separator jSeparator3;
    private javax.swing.JPopupMenu.Separator jSeparator4;
    // End of variables declaration//GEN-END:variables
}
